{
char *enomem = "[out of memory formatting log message]";
char *s;
- int rc;
+ int rc, esave;
if (!ctx->log_callback)
return;
+ esave = errno;
+
rc = vasprintf(&s, fmt, ap);
if (rc<0) { s = enomem; goto x; }
ctx->log_callback(ctx->log_userdata, loglevel, file, line, func, s);
if (s != enomem)
free(s);
+ errno = esave;
}
void xl_log(struct libxl_ctx *ctx, int loglevel, int errnoval,
#define XL_LOG_ERRNO(ctx, loglevel, _f, _a...)
#define XL_LOG_ERRNOVAL(ctx, loglevel, errnoval, _f, _a...)
#endif
+ /* all of these macros preserve errno (saving and restoring) */
#define XL_LOG_DEBUG 3
#define XL_LOG_INFO 2
/* logging */
void xl_logv(struct libxl_ctx *ctx, int errnoval, int loglevel, const char *file, int line, const char *func, char *fmt, va_list al);
void xl_log(struct libxl_ctx *ctx, int errnoval, int loglevel, const char *file, int line, const char *func, char *fmt, ...);
+ /* these functions preserve errno (saving and restoring) */
typedef enum {